//Detail组件的mixin
import { mhDetailsApi } from "../../api/data";
export default {
    data() {
        return {
            isShow: false, //是否显示操作栏
            popup: false, //是否显示章节列表
            index: null, //当前漫画的章节
            timer: true, //延时执行
            timerFn: null, //节流的函数
            isShowMark: false, //是否显示遮罩层
        }
    },
    methods: {
        back() {
            //回退到漫画上一个界面
            let url = window.sessionStorage.getItem('parentUrl')
            this.$router.push({
                path: '/about',
                query: {
                    url: url
                },
            })
        },
        async getList(id) {
            this.isShowMark = true
            this.isShow = false
            this.popup = false
            let origin = await mhDetailsApi(id)
            console.log(origin)
            let { data } = origin.data
            this.isShowMark = false
            return data || []
        },
        //状态框 取消回调
        cancle() {
            this.isShow = false
            this.popup = false
        },
        choseType() {
            console.log('点击了')
            this.isShow ? (this.isShow = false) : (this.isShow = true)
            console.log(this.isShow)
        },
        more() {
            let { url } = this.json
            this.mhlist = JSON.parse(window.sessionStorage.getItem('mhList'))
            this.mhlist.forEach((item, index) => {
                if (item.chapterId === url) {
                    this.index = index
                    return false
                }
            });
            this.popup = true
        },
        goDetail(item) {
            // Object.assign(this.json, {
            //     url: item.chapterId,
            //     num: item.title
            // })
            this.json =
            {
                url: item.chapterId,
                num: item.title
            }
            this.getData()
        }
    },
}